package news

import (
	"parking-lot-go-dingding/controller"
	"parking-lot-go-dingding/model/dingtalk"

	"github.com/gin-gonic/gin"
)

func List(c *gin.Context) {

	requestStruct := struct {
		ClassId int `json:"class_id"`
	}{}

	//接收加密串
	if err := c.ShouldBindJSON(&requestStruct); err != nil {
		controller.Fail(c, "json接收失败")
		return
	}

	var dingtalkNewsStruct dingtalk.DingtalkNewsStruct
	dingtalkNewsData, err := dingtalkNewsStruct.List(requestStruct.ClassId, "", 1, 10)
	if err != nil {
		controller.Fail(c, err.Error())
		return
	}

	controller.Success(c, dingtalkNewsData)
}
